﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class AdminHosp : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    private void Bind()
    {
        string sql = string.Format("select Doctor.Name as DocName,Hospitalizat.*,Patient.Name from Hospitalizat INNER JOIN Patient ON Hospitalizat.PatIDCard = Patient.IDCard INNER JOIN Doctor ON Hospitalizat.DocID = Doctor.ID");
        DataSet set = DBHelper.GetDataSet(sql);
        GridView1.DataSource = set;
        GridView1.DataKeyNames = new string[] { "ID" };
        GridView1.DataBind();
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
    }


    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        Bind();
    }
}